package com.bdd.Enum;

import com.bdd.entity.Discount;

public enum DiscountEnum {
    ONE("一折", 0.1),
    ONEF("一五折", 0.15),
    TWO("二折", 0.2),
    TWOF("二五折", 0.25),
    THREE("三折", 0.3),
    THREEF("三五折", 0.35),
    FOUR("四折", 0.4),
    FOURF("四五折", 0.45),
    FIVE("五折", 0.5),
    FIVEF("五五折", 0.55),
    SIX("六折", 0.6),
    SIXF("六五折", 0.65),
    SEVEN("七折", 0.7),
    SEVENF("七五折", 0.75),
    NIGHT("八折", 0.8),
    NIGHTF("八五折", 0.85),
    TEN("九折", 0.9),
    TENF("九五折", 0.95);
    private String discountName;
    private Double discount;
    DiscountEnum(String discountName, Double discount) {
        this.discountName = discountName;
        this.discount = discount;
    }

    public static String getNameByDiscount(Double discount) {
        for (DiscountEnum discountEnum : DiscountEnum.values()) {
            if (discountEnum.discount == discount) {
                return discountEnum.discountName;
            }
        }
        return null;
    }

    public static Double getDiscountByName(String discountName){
        for(DiscountEnum discountEnum : DiscountEnum.values()){
            if (discountEnum.discountName.equals(discountName)){
                return discountEnum.discount;
            }
        }
        return null;
    }

}
